//导入路由
import React, { Component, lazy, Suspense } from "react";
import { Switch, Route, Redirect, withRouter } from "react-router-dom";
import Tabbar from "../components/Tabbar";

//定义导航链接
//rcc 生成类组件
//rsf 生成函数式组件
import "../styles/Index.scss";

var Home = lazy(() => import("./Index/Shouye"));
var NotFound = lazy(() => import("./NotFound"));
var Register = lazy(() => import("./Register"));
var Fenlei = lazy(() => import("./Index/Fenlei"));
var Car = lazy(() => import("./Index/Car"));
var Mine = lazy(() => import("./Index/Mine"));

var Dizhilist = lazy(() => import("./Index/Dizhilist"));
var Shoucang = lazy(() => import("./Index/Shoucang"));

var Dingdan = lazy(() => import("./Index/Dingdan"));

class Index extends Component {
  constructor(props) {
    super(props);
    this.taber = {
      //  courIndex:0,
    };
  }
  Dizhilist;

  render() {
    return (
      <div className="app">
        <Suspense fallback={<div className="loading">loading.....</div>}>
          <Switch>
            <Route exact path="/index/shouye" component={Home} />
            {/* 首页界面 */}
            <Route exact path="/index/Fenlei" component={Fenlei} />
            {/* 分类界面 */}
            <Route exact path="/index/Car" component={Car} />
            {/* 购物车界面 */}
            <Route exact path="/index/Mine" component={Mine} />
            {/* 我的界面 */}
            <Route exact path="/index/Shoucang" component={Shoucang} />
            {/* 收藏页面 */}
            <Route exact path="/index/Dizhilist" component={Dizhilist} />
            {/* 地址列表界面 */}
            <Route exact path="/index/register" component={Register} />
            {/* 注册界面 */}
            <Route exact path="/index/Dingdan" component={Dingdan} />
            {/* 订单界面 */}

            <Redirect exact from="" to="/index/shouye" />
            {/* 登陆界面 */}
            <Redirect exact from="/index" to="/index/shouye" />
            {/* 重定向界面 */}
            <Route path="*" component={NotFound} />
            {/* 所有界面 路径错误找不到404 */}
          </Switch>
        </Suspense>
        <Tabbar></Tabbar>
      </div>
    );
  }
}

export default withRouter(Index);
